package com.mall.weapp.controller;

import com.mall.weapp.common.CommonResult;
import com.mall.weapp.model.vo.BrandVo;
import com.mall.weapp.model.vo.ProductListVo;
import com.mall.weapp.service.BrandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/brand")
public class BrandController {

    @Autowired
    private BrandService brandService;

    @GetMapping("/all")
    public CommonResult<List<BrandVo>> getAllBrand(){
        List<BrandVo> brandList = brandService.getBrandList();
        return CommonResult.success(brandList);
    }

    @GetMapping("/getProductById")
    public CommonResult<List<ProductListVo>> getProductById(long id){
        List<ProductListVo> productList = brandService.getProductByBrandId(id);
        return CommonResult.success(productList);
    }
}
